package com.pbq.pickerlib.wheel.adapters;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by remilia on 2016/10/12.
 */
public class WheelTextAdapter extends AbstractWheelTextAdapter {

    public WheelTextAdapter(Context context) {
        super(context);
    }

    private List<String> mList = new ArrayList<>();

    public void setList(List<String> list) {
        mList.clear();
        mList.addAll(list);
    }

    public void setList(String[] strs) {
        mList.clear();
        for (int i = 0; i < strs.length; i++) {
            mList.add(strs[i]);
        }
    }

    public List<String> getList() {
        return mList;
    }

    @Override
    public CharSequence getItemText(int index) {
        if (mList != null && mList.size() > index) {
            return mList.get(index);
        } else {
            return "";
        }
    }

    @Override
    public int getItemsCount() {
        return mList.size();
    }
}
